package com.lgy.web.security;

import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

import java.util.ArrayList;

/**
 * Created by fengch on 2017/5/29.
 */
public class MyUserDetailsService implements UserDetailsService {
    @Override
    public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
        //根据用户名从db中查找用户在赋值给User
        //...
        ArrayList list = new ArrayList();
        list.add(new SimpleGrantedAuthority("ROLE_SUPERVISOR"));
        User details = new User("feng", "123", list);
        return details;
    }
}
